﻿using System;
using System.Collections.Generic;
using System.Text;
using UtilZ.Dotnet.Ex.Base;

namespace UtilZ.Dotnet.Ex.Communication.Net.Telnet.KeyCommands
{
    internal class EnterCommand : TelnetKeyCommandAbs
    {
        /**********************************************
         *          windows  linux      mac
         * code     13-10    13-0       13-0
         **********************************************/

        public EnterCommand()
              : base()
        {

        }

        protected override bool PrimitveProcess(ListenTelnetClient telnetClient, byte[] data, int revicedDataLength)
        {
            if (revicedDataLength != 2)
            {
                return false;
            }

            if ((telnetClient.Platform == OSPlatformID.MacOS || telnetClient.Platform == OSPlatformID.Linux_Unix) && data[0] == 13 && data[1] == 0 ||
                telnetClient.Platform == OSPlatformID.Win && data[0] == 13 && data[1] == 10)
            {
                telnetClient.ProcessMessage();
                return true;
            }

            return false;
        }

    }
}
